package com.woniu.register.service.impl;

import com.woniu.register.dto.OwnerDTO;
import com.woniu.register.entity.Owner;
import com.woniu.register.mapper.OwnerMapper;
import com.woniu.register.service.OwnerService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 所有权初始登记服务类
 *
 * @author 晨星
 * @date 2022/12/7 19:56
 **/
@Service
public class OwnerServiceImpl implements OwnerService {

    private final OwnerMapper ownerMapper;

    public OwnerServiceImpl(OwnerMapper ownerMapper) {
        this.ownerMapper = ownerMapper;
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(Owner record) {
        return 0;
    }

    @Override
    public int insertSelective(Owner record) {
        return 0;
    }

    @Override
    public Owner selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Owner record) {
        return ownerMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Owner record) {
        return 0;
    }

    @Override
    public List<String> selectFile(Integer num) {
        List<String> list = null;
        if (num == 1) {
            list = ownerMapper.selectFile();
        } else if (num == 2) {
            list = ownerMapper.selectFile2();
        }
        return list;
    }

    @Override
    public int insertOwner(OwnerDTO owner) {
        Owner owner1 = new Owner();
        Date date = new Date();
        String time = String.valueOf(date.getTime());
        owner1.setBusinessNum(time);
        owner1.setDirectoryId(owner.getDirectoryId());
        owner1.setProposerId(owner.getProposerId());
        owner1.setPrecontractStatus("<已受理>");
        owner1.setCommonerId(owner.getCommonerId());
        owner1.setOwnerErtificateNum("这是所有权证明号");
        owner1.setRegisterTime(date);
        owner1.setOwnerTypeId(owner.getTypeId());
        return ownerMapper.insertOwner(owner1);
    }
}
